home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / lfs / lfsTypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  9.5 KB  |  226 lines

  1. /*
  2.  * lfsTypes.h --
  3.  *
  4.  *    Type definitions for the LFS module.
  5.  *
  6.  * Copyright 1992 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/lfs/lfsTypes.h,v 1.2 92/09/03 18:13:32 shirriff Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _LFSTYPES
  19. #define _LFSTYPES
  20.  
  21. #include <lfsDesc.h>
  22. #include <lfsDescMap.h>
  23. #include <lfsDirOpLog.h>
  24. #include <lfsUsageArray.h>
  25. #include <lfsFileLayout.h>
  26. #include <lfsSuperBlock.h>
  27. #include <lfsStats.h>
  28.  
  29. /* Types from LfsDescInt.h */
  30. /*
  31.  * LfsDescCache - Data structure defining the cache of file descriptor blocks
  32.  *                maintained by a LFS file system.  The current implementation
  33.  *                caches descriptor map blocks in files the file cache.
  34.  */
  35.  
  36. typedef struct LfsDescCache {
  37.     Fsio_FileIOHandle handle; /* File handle use to cache descriptor
  38.                                * block under. */
  39. } LfsDescCache;
  40.  
  41. /* Types from LfsDirLogInt.h */
  42. typedef struct LfsDirLog {
  43.     int                 nextLogSeqNum;  /* The next log sequence number to be
  44.                                          * allocated. */
  45.     LfsDirOpLogBlockHdr *curBlockHdrPtr; /* The log block header of the block
  46.                                          * current being filled in. */
  47.     char                *nextBytePtr;   /* The next available byte in the
  48.                                          * block being filled in. */
  49.     int                 bytesLeftInBlock;/* Number of bytes left in the
  50.                                           * block being filled in. */
  51.     List_Links          activeListHdr;   /* List cache blocks of log blocks. */
  52.     List_Links          writingListHdr;   /* List cache blocks of log blocks
  53.                                            * being written. */
  54.     Fsio_FileIOHandle   handle;          /* File handle used to cache blocks
  55.                                           * under. */
  56.     int                 leastCachedSeqNum; /* The least log sequence number in
  57.                                             * the in memory log. */
  58.     Boolean             paused;         /* Log traffic is currently paused. */
  59.     Sync_Condition      logPausedWait;  /* Wait for paused to become false. */
  60. } LfsDirLog; 
  61.  
  62. /* Types from LfsStableMem.h */
  63. typedef struct LfsStableMem {
  64.     struct Lfs        *lfsPtr;          /* File system for stable memory. */
  65.     Fsio_FileIOHandle dataHandle;       /* Handle used to store blocks in
  66.                                          * cache under. */
  67.     LfsDiskAddr *blockIndexPtr;         /* Index of current disk addresses. */
  68.     int         numCacheBlocksOut;      /* The number of cache blocks currently
  69.                                          * fetched by the backend. */
  70.     LfsStableMemCheckPoint checkPoint; /* Data to be checkpoint. */
  71.     LfsStableMemParams params;  /* A copy of the parameters of the index. */
  72. } LfsStableMem;
  73.  
  74. typedef struct LfsStableMemEntry {
  75.     Address     addr;                   /* Memory address of entry. */
  76.     Boolean     modified;               /* TRUE if the entry has been
  77.                                          * modified. */
  78.     int         blockNum;               /* Block number of entry. */
  79.     ClientData  clientData;             /* Clientdata maintained by
  80.                                          * StableMem code. */
  81. } LfsStableMemEntry;
  82.  
  83. /* Types from LfsDescMapInt.h */
  84. typedef struct LfsDescMap {
  85.     LfsStableMem        stableMem;/* Stable memory supporting the map. */
  86.     LfsDescMapParams    params;   /* Map parameters taken from super block. */
  87.     LfsDescMapCheckPoint checkPoint; /* Desc map data written at checkpoint. */
  88. } LfsDescMap;
  89.  
  90. /* Types from lfsSegUsageInt.h */
  91. typedef struct LfsSegUsage {
  92.     LfsStableMem        stableMem;/* Stable memory supporting the map. */
  93.     LfsSegUsageParams   params;   /* Map parameters taken from super block. */
  94.     LfsSegUsageCheckPoint checkPoint; /* Desc map data written at checkpoint. */
  95.     int                 timeOfLastWrite; /* Time of last write of current
  96.                                           * segment. */
  97. } LfsSegUsage;
  98.  
  99. typedef struct LfsSegList {
  100.     int segNumber;      /* Segment number of segment. */
  101.     int activeBytes;    /* Active bytes from the seg usage array. */
  102.     unsigned int priority;      /* Priority for the space-time sorting. */
  103. } LfsSegList;
  104.  
  105. /* Types from LfsFileLayoutInt.h */
  106. typedef struct LfsFileLayout {
  107.     LfsFileLayoutParams  params;        /* File layout description. */
  108. } LfsFileLayout;
  109.  
  110. /* Types from LfsMemInt.h */
  111. /*
  112.  * LfsMem - Per LFS file system resource list.
  113.  */
  114. typedef struct LfsMem {
  115.     int cacheBlocksReserved; /* Number of cache blocks reserved for this file
  116.                               * system. */
  117. } LfsMem;
  118.  
  119. /* Types from LfsInt.h */
  120.  
  121. /*
  122.  * LfsCheckPoint contains the info and memory needed to perform checkpoints.
  123.  * The file system timestamp and the next checkpoint area to write
  124.  * indicator are kept here. 
  125.  */
  126. typedef struct LfsCheckPoint {
  127.     int      timestamp;    /* Current file system timestamp. */
  128.     int      nextArea;    /* Next checkpoint area to write. Must be 0 or 1. */
  129.     char  *buffer;    /* Memory buffer to place checkpoint. */
  130.     int      maxSize;    /* Maximum size of the buffer. */
  131. } LfsCheckPoint;
  132.  
  133. /*
  134.  * LfsSegCache - Data structure describing the in memory cache of segments.  
  135.  * With the current implementation, this cache contains the last segment
  136.  * read during cleaning and it takes any hits during cleaning.
  137.  */
  138. typedef struct LfsSegCache {
  139.     Boolean valid;            /* TRUE if the cache contains valid data. */
  140.     int        segNum;        /* The segment number being cached. */
  141.     LfsDiskAddr  startDiskAddress;  /* The starting and ending disk address */
  142.     LfsDiskAddr  endDiskAddress;    /* of the cached segment.  */
  143.     char    *memPtr;        /* Memory location of segment. */
  144. } LfsSegCache;
  145.  
  146. /*
  147.  * Lfs - The main data structure describing an LFS file system.
  148.  */
  149. typedef struct Lfs {
  150.         /*
  151.          * Fields that are set at attach time and then read-only
  152.          * until detach.
  153.          */
  154.     Fs_Device      *devicePtr;    /* Device containing file system. */
  155.     char      *name;    /* Name used for error messages. */
  156.     int          controlFlags;    /* Flags controlling file system operating. 
  157.                  * see lfs.h for definitions.  */
  158.     Fsdm_Domain      *domainPtr;    /* Domain this file system belongs. */
  159.     /*
  160.      * Routine for cache backend. 
  161.      */
  162.     Sync_Lock      cacheBackendLock; /* Lock for cache backend use. */
  163.     Boolean       writeBackActive; /* TRUE if cache backend is active. */
  164.     Boolean        writeBackMoreWork; /* TRUE if more work is available for
  165.                        * the cache backend. */
  166.     Boolean       shutDownActive;   /* TRUE if the file system is being 
  167.                       * shutdown. */
  168.     int          cacheBlocksReserved; /* Number of file cache blocks
  169.                     * reserved for file system. */
  170.     int             attachFlags;    /* Flags from Lfs_AttachDisk() call.  */
  171.     int                blockSizeShift;   /* Log base 2 of blockSize. Used by
  172.                      * Blocks<->Bytes macros below to 
  173.                      * use fast shifts rather than costly 
  174.                      * multiplies and divides. */
  175.     int    *checkpointIntervalPtr; /* A pointer to the interval to call
  176.                 * the checkpoint processor on. A 
  177.                 * value of zero will cause the 
  178.                 * checkpoint process to stop. */
  179.         /*
  180.          * Fields modified after boot that require locking.
  181.          */
  182.     Sync_Lock      lock;    /* Lock protecting the below data structures. */
  183.     int        activeFlags;    /* Flags specifing what processes are active
  184.                  * on file system. See below for values. */
  185.     Proc_ControlBlock *cleanerProcPtr; /* Process Control block of cleaner
  186.                     * process. NIL if cleaner is not
  187.                     * active. */
  188.     Sync_Condition writeWait; /* Condition to wait for the file system 
  189.                    * write to complete. */
  190.     Sync_Condition cleanSegmentsWait; /* Condition to wait for clean
  191.                        * segments to be generated. */
  192.     Sync_Condition checkPointWait; /* Condition to wait for checkpoint
  193.                     * completing or starting. */
  194.     int        dirModsActive;    /* Number of processes inside directory 
  195.                  * modification code. */
  196.     int        numDirtyBlocks; /* Estimate of the number of dirty blocks
  197.                  * in the file cache. */
  198.     LfsSegCache   segCache;      /* Cache of recently read segments. */
  199.     LfsDescCache  descCache;      /* Cache of file desciptors. */
  200.     Sync_Lock     logLock;    /* Lock protecting the directory log. */
  201.     LfsDirLog      dirLog;     /* Directory change log data structures. */
  202.     Boolean      segMemInUse;    /* TRUE if segment memory is being used. */
  203.     LfsDescMap      descMap;    /* Descriptor map data. */
  204.     LfsSegUsage   usageArray;   /* Segment usage array data. */
  205.     Sync_Lock     checkPointLock; /* Lock protecting the checkpoint data. */
  206.     LfsCheckPoint checkPoint;   /* Checkpoint data. */
  207.     LfsFileLayout fileLayout;    /* File layout data structures. */
  208.     LfsSuperBlock superBlock;    /* Copy of the file system's super block 
  209.                  * read at attach time. */
  210.     Lfs_Stats    stats;        /* Stats on the file system.  */
  211.     /*
  212.      * Segment data structures. Currently three segments are 
  213.      * preallocated: one for writing, one for cleaning, and one for the
  214.      * checkpoint processes.
  215.      */
  216. #define    LFS_NUM_PREALLOC_SEGS    3
  217.  
  218.     int        segsInUse;
  219.     struct LfsSeg *segs;
  220.     char   *writeBuffers[2];    /* Buffers used to speed segment writes. */
  221.     LfsMem    mem;        /* Memory resources allocated to file system. */
  222. } Lfs;
  223.  
  224. #endif /* _LFSTYPES */
  225.  
  226.